package dao;

import java.nio.Buffer;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

// 通过这个类的对象 表示一条 blog 表中的记录.
// 这个类的属性要和 blog 表的列匹配.
public class Blog {
    private int blogId;
    private  String title;
    private String content;
    private int userId;
    private  Timestamp postTime;

    public int getBlogId() {
        return blogId;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }

    public int getUserId() {
        return userId;
    }

    public String getPostTime() {//返回类型timestamp会被json当成时间戳看待，修改党法返回一个string
        //需要把时间戳转换成格式化时间
        SimpleDateFormat ft=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String postTimes=ft.format(postTime);
        return postTimes;

    }

    public void setBlogId(int blogId) {
        this.blogId = blogId;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public void setPostTime(Timestamp postTime) {
        this.postTime = postTime;
    }
    @Override
    public String toString() {
        return "Blog{" +
                "blogId=" + blogId +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", userId=" + userId +
                ", postTime=" + postTime +
                '}';
    }
}
